import { Controller, Get, Query } from '@nestjs/common';
import { HomeService as Service } from '../services/home.service';

@Controller('home')
export class HomeController {

    constructor(private readonly service: Service) { }

    /**
 * 测试获取列表
 */
    @Get()
    async getHome(): Promise<any> {

        const list=await this.service.getBusiness([]);
        let strHtml='';
        for(let i=0;i<list.length;i++){
            let item=list[i];
            strHtml+='<div class="item">'+item.id+'我的标题</div>';
        }
        return  strHtml
    }

    /**
    * 查询设备总数
    * @param query
    */
    @Get('getCounts')
    async getCounts(@Query() query): Promise<any> {
        return this.service.getCounts(query);
    }

    /**
     * 获取气象数据
     * @param query 
     */
    @Get('getSensor')
    async getSensor(@Query() query): Promise<any> {
        return this.service.getSensor(query);
    }

    /**
    * 获取监控数据
    * @param query 
    */
    @Get('getMonitor')
    getMonitor(@Query() query) {
        return '监控数据';
    }

    /**
    * 获取告警统计数据
    * @param query 
    */
    @Get('getAlert')
    getAlert(@Query() query) {
        return this.service.getAlert(query);
    }

    /**
    * 获取能耗数据
    * @param query 
    */
    @Get('getEnergy')
    getEnergy(@Query() query) {
        return this.service.getEnergy(query);
    }

    /**
    * 获取灯杆数据
    * @param query 
    */
    @Get('getLamppost')
    getLamppost(@Query() query) {
        return this.service.getLamppost(query);
    }


}
